package com.lc.user.express.httpserver;

import android.util.Log;

import com.lc.user.express.model.HomeModel;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/3/30.主页
 */
@HttpInlet(Net.GET_INDEX)
public class GetIndex extends ZJDBAsyGet<GetIndex.Info> {
    public String areaid,point;

    public GetIndex(String point,String areaid, AsyCallBack listener) {
        super(listener);
        this.point = point;
        this.areaid = areaid;
    }

    @Override
    protected Info parser(JSONObject object) {
        if (object.optInt("message") == 1) {
            Info info = new Info();
            info.number = object.optInt("number");
            JSONArray array = object.optJSONArray("list");
            if (array != null) {
                for (int i = 0; i < array.length(); i++) {
                    JSONObject object1 = array.optJSONObject(i);
                    HomeModel model = new HomeModel();
                    model.setId(object1.optString("id"));
                    model.setPicUrl(object1.optString("picurl"));
                    model.setCarName(object1.optString("cartype"));
                    model.setMoney(object1.optString("price"));
                    //   model.setMiles("5");
                    model.setMiles(object1.optString("unit"));
                    Log.i("unit", model.getMiles());
                    model.setWeight(object1.optString("load"));
                    model.setVolum(object1.optString("long") + "X" + object1.optString("wide") + "X" + object1.optString("high"));
                    model.setSuperFee(object1.optString("cost"));
                    info.dataList.add(model);
                }

            }
            return info;
        } else {
            TOAST = "";
        }
        return null;
    }

    public static class Info {
        public int number;
        public List<HomeModel> dataList = new ArrayList<>();

    }
}
